package kuzha.runtime.jadapter;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;

import kuzha.KuzhaObject;
import kuzha.runtime.Converter;

public class FromSetAdapter<T> extends AbstractSet<KuzhaObject> {
	private final Set<T> set;
	private final Class<T> cls;
	
	public FromSetAdapter(Set<T> set, Class<T> cls) {
		this.set = set;
		this.cls = cls;
	}
	
	public boolean add(KuzhaObject arg0) {
		return set.add(Converter.cast(cls, arg0));
	}
	
	public void clear() {
		set.clear();
	}
	
	public boolean contains(Object arg0) {
		return set.contains(arg0);
	}
	
	public Iterator<KuzhaObject> iterator() {
		return new FromIteratorAdapter(set.iterator());
	}
	
	public int size() {
		return set.size();
	}
}
